﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyBanHang.Lib;
using QuanLyBanHang.GUI;

namespace QuanLyBanHang.GUI
{
    public partial class frmLogin : Form
    {
        #region "Variables"
        public DataTable dtbUser;
        public  int _Permission;
        public  string _user;
        #endregion
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            dtbUser = KetNoi.GetTable("select * from tblNhanVien where MaNhanVien = '"+txtUser.Text+"'and MatKhau = '"+txtPass.Text.Trim()+"'");
            if (dtbUser.Rows.Count > 0)
            {
                _Permission = Int32.Parse(dtbUser.Rows[0]["CapDo"].ToString());
                _user = dtbUser.Rows[0]["MaNhanVien"].ToString();

                frmMain frm = new frmMain(_user, _Permission);
                frm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu sai");
            }
            
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
